import Nanobot, Grid, Main, pygame
class Testbot(Nanobot.Nanobot):

    def __init__(self,loc,gridsize):
        Nanobot.Nanobot.__init__(self,loc,gridsize,visionRadius = 3)
        
    def performAction(self):
        if self.goalCheck():
            return
        goalLocs = self.nanoVision()
        if goalLocs:
            (newY, newX) = self.moveTo(goalLocs[0])
        else:    
            (newY, newX) = self.nanoRand()
        
        try:
            self.board.gridrepr[self.loc[0]][self.loc[1]].contents.remove(self)
        except ValueError:
            pass
        self.loc[0] = newY
        self.loc[1] = newX
        self.rect.topleft = [self.loc[0]*10, self.loc[1]*10]
        self.board.gridrepr[self.loc[0]][self.loc[1]].contents.append(self)
